<?php

	error_reporting(E_ALL);

	class Menu {

		function CallFunctions($list=array(),$rss=NULL){
			
			unset($GLOBALS['str']);
			echo Parser::Parse(array('template'=>'/template/menu.tpl','bbcode'=>FALSE),
								array('{QUICKLIST}','{RSS}'),
								array(Menu::CompileQuickList($list),Menu::RSS($rss)));

			include($_SERVER['DOCUMENT_ROOT'] . '/template/footer.tpl');

		}
		
		function RSS($rss){
		
			if(empty($rss)){
				$rss = 'No RSS feed for this page.';
			} else {
			
				$rss = '<span class="date">RSS feed for this page</span>
                    <p><a href="http://myphpdigest.com/RSS/'.$rss.'.rss">
                    <img alt="My PHP Digest RSS Feed" src="http://myphpdigest.com/images/icons/feed.png" /></a></p>';
					
			}
			return $rss;

		}
		
		function CompileQuickList($list=array()){
			
			if(empty($list)){
				$list[] = 'No quicklist items.';
			}
			
			$st = '<ul>';
			foreach($list as $l){
			
				if(strlen($l) > 24){
					$l=preg_replace_callback("/<a href=(.*?)>(.*?)<\\/a>/i",array('Menu','WordLimit'),$l);
				}
				
				if(!(strstr($l, "h2"))){
					$st .= '<li>'.$l.'</li>';
				} else {
					$st .= $l;
				}
			}

			return $st.'</ul>';
		}

		
		function WordLimit($s){
			return '<a href='.$s[1].'>'.substr($s[2], 0, 24).'</a>';
		}

	}

?>